﻿using Microsoft.Xna.Framework;

namespace SaveTheQueen.Utils.Colision
{
    public class InnerCircleShape : BaseShape
    {
        public override bool Intersect(Component.Sprite a, Component.Sprite b)
        {
            Vector2 aCenter;
            Vector2 bCenter;
            float aRadius, bRadius;

            aCenter = CreateFromSprite(a, out aRadius);
            bCenter = CreateFromSprite(b, out bRadius);

            if ((aRadius + bRadius) > Vector2.Distance(aCenter, bCenter))
                return true;
            else
                return false;
        }

        private Vector2 CreateFromSprite(Component.Sprite sprite, out float radius)
        {
            if (sprite.Size.X < sprite.Size.Y)
                radius = sprite.Size.X / 2;
            else
                radius = sprite.Size.Y / 2;

            return (sprite.Position + (sprite.Size * sprite.Scale) / 2);
        }
    }
}
